import dayjs from 'dayjs'
const filterTimers=(val,format='YYYY-MM-DD')=>{
    console.log(val,'val')
    // 如果是时间戳*1000
    if(!isNull(val)){
        return dayjs(val).format(format)
    }else{
        return '--'
    }
}
export const isNull=(date)=>{
    if(!date || JSON.stringify(date)==('{}'||'[]')) return true
}

export default (app)=>{
    app.config.globalProperties.$filters={
        filterTimers
    }
}
   const checkedType = (target) => Object.prototype.toString.call(target).replace(/\[object (\w+)\]/, "$1").toLowerCase();

export const deepClone = (target) => {
      let result;
      let type = checkedType(target);
      console.log(type)
      if(type === 'object') result = {};
      else if(type === 'array') result = [];
      else  return target;
      for (let key in target) {
          if(checkedType(target[key]) === 'object' || checkedType(target[key]) === 'array') {
              result[key] = deepClone(target[key]);
          } else {
              result[key] = target[key]; 
          }
      }
      return result;
  }